<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>4047：[Cerc2014] The Imp</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Cerc2014] The Imp</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Cerc2014] The Imp</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Cerc2014] The Imp                </h1>
                <p>时间限制：2s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>You arrive m Ye Olde Magic Shoppe with some hard-earned gold to purchase wondrous and&nbsp;</div>
<div>unique magic items. There are n such items in the shop, each of them locked in a special magic&nbsp;</div>
<div>box. The i-th box costs ci gold pieces to buy, and contains an item worth vi gold pieces. The&nbsp;</div>
<div>costs and item values are known to you, as you have previously read, mastered, and memorized&nbsp;</div>
<div>Ye Olde Magic Catalogue.&nbsp;</div>
<div>A mortal, such as you, can safely carry only one magic item. You therefore aim to get the&nbsp;</div>
<div>most precious one. And obtain it you would, if not for a malicious, magical creature, known as&nbsp;</div>
<div>The Imp.&nbsp;</div>
<div>The Imp can cast a mischievous spell, which transforms the content of any magic box into&nbsp;</div>
<div>worthless dust. Of course, he will use the spell just after you buy a box, to make you pay for the&nbsp;</div>
<div>item and not get it. You are thus forced to buy another box, and then the next one_&nbsp;</div>
<div>The Imp has enough magic to cast the spell at most k times. He can, of course, refrain from&nbsp;</div>
<div>using it, allowing you to keep an item. You can walk away at any time, empty-handed (though&nbsp;</div>
<div>it would surely be a disgrace). However, if you get an item, you must keep it and leave the shop.&nbsp;</div>
<div>You aim to maximize your gain (the value of the acquired item minus all the expenses paid&nbsp;</div>
<div>previously), while The Imp wants to mimmize it. If both vou and the creature use the optimal&nbsp;</div>
<div>strategy, how much gold will vou earn?&nbsp;</div>
<div>T组询问。每组询问：&nbsp;</div>
<div>第一行有两个数字N,K，表示有N个物体，接下来每个物体有2个描述权值Vi, Ci，表示该物体的价值和价格。</div>
<div>商家很坑，他有K次机会使得你买完物品之后就立马让你买的该物品消失（但已经付了钱），而商家的目标</div>
<div>则是使得你的净收入尽量低。你可以无限量买东西，但最后只能带走一件物品，不过当然想要使得净收入尽</div>
<div>量高。在双方皆采取最佳策略的情况下，你最多能得到多少钱？（当然，你也可以什么都不买）&nbsp;</div>
<div></div>
<p></p></p><hr/><h3>输入格式</h3><p><div>The first line of input contains the number of test cases T. The descriptions of the test cases&nbsp;</div>
<div>follow:&nbsp;</div>
<div>Each test case starts with a line containing the number of items n (1《n&le; 150 000) and the&nbsp;</div>
<div>the maximum number of The Imp's spells k (0&le; k &lt; 9). The next n lines contain the items'&nbsp;</div>
<div>values and costs, the i-th line containing the numbers vi and ci, in that order (0&le; vi, ci&le; 10^6).&nbsp;</div>
<div></div>
<p></p></p><hr/><h3>输出格式</h3><p><div>For each test case, output one line containing your gain</div>
<div>
<div></div>
</div>
<p></p></p><hr/><h3>样例输入</h3><pre>1
3 1
10 5
8 1
20 12</pre><hr/><h3>样例输出</h3><pre>7</pre><hr/><h3>提示</h3><p>没有写明提示</p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=4047" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=4047" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>